package com.zhm.demo.grpc;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;
import proto.DemoGrpc;
import proto.DemoOuterClass;


@Slf4j
@Service
public class DemoGrpcClient {

    @GrpcClient("demo")
    private DemoGrpc.DemoBlockingStub demoBlockingStub;

    @PostConstruct
    public void init() {
//        new Thread(() -> {
//            try {
//                Thread.sleep(15000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//            log.info("demoBlockingStub:{}", demoBlockingStub);
//            DemoOuterClass.LoginResp authorization = demoBlockingStub.login(DemoOuterClass.LoginReq.newBuilder().setUsername("123").build());
//            log.info("authorization:{}", authorization);
//        }).start();
    }
}
